home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / lst / RCS / lstMove.c,v < prev    next >
Encoding:
Text File  |  1992-05-19  |  2.0 KB  |  93 lines

  1. head     1.6;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.6
  10. date     89.06.13.15.01.48;  author adam;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.6
  21. log
  22. @checked in with -k by kupfer at 92.05.18.17.32.44.
  23. @
  24. text
  25. @/*-
  26.  * LstMove.c --
  27.  *    Move an existing node after or before one in the same or different
  28.  *    list.
  29.  *
  30.  * Copyright (c) 1988 by University of California Regents
  31.  *
  32.  * Permission to use, copy, modify, and distribute this
  33.  * software and its documentation for any purpose and without
  34.  * fee is hereby granted, provided that the above copyright
  35.  * notice appears in all copies.  Neither the University of California nor
  36.  * Adam de Boor makes any representations about the suitability of this
  37.  * software for any purpose.  It is provided "as is" without
  38.  * express or implied warranty.
  39.  */
  40. #ifndef lint
  41. static char *rcsid =
  42. "$Id: lstMove.c,v 1.6 89/06/13 15:01:48 adam Exp $ SPRITE (Berkeley)";
  43. #endif lint
  44.  
  45. #include    "lstInt.h"
  46.  
  47. /*-
  48.  *-----------------------------------------------------------------------
  49.  * Lst_Move --
  50.  *    Move a node after or before a destination node. The nodes do not
  51.  *    need to be in the same list, of course.
  52.  *
  53.  * Results:
  54.  *    SUCCESS or FAILURE.
  55.  *
  56.  * Side Effects:
  57.  *    The firstPtr and lastPtr fields of either or both of the involved
  58.  *    lists may be altered to reflect reality.
  59.  *
  60.  *-----------------------------------------------------------------------
  61.  */
  62. ReturnStatus
  63. Lst_Move (ls, lns, ld, lnd, before)
  64.     Lst                    ls;     /* Source list */
  65.     register LstNode      lns;    /* source list node */
  66.     Lst                    ld;     /* Destination list */
  67.     register LstNode      lnd;    /* destination list node */
  68.     Boolean        before;    /* true if should use Lst_Insert */
  69. {
  70.     ClientData    d;
  71.     ReturnStatus    rval;
  72.     
  73.     if (lns == NILLNODE || lnd == NILLNODE) {
  74.     return (FAILURE);
  75.     }
  76.     
  77.     d = ((ListNode)lns)->datum;
  78.     
  79.     if (Lst_Remove (ls, lns) == FAILURE) {
  80.     return (FAILURE);
  81.     }
  82.     
  83.     if (before == TRUE) {
  84.     rval = Lst_Insert (ld, lnd, d);
  85.     } else {
  86.     rval = Lst_Append (ld, lnd, d);
  87.     }
  88.     
  89.     return (rval);
  90. }
  91.  
  92. @
  93.